<?php

function connect_db($config) {
	$link = mysql_connect('localhost',$config['username'],$config['password']);
	if (!$link) {
		die('Not connected : ' . mysql_error());
	} else {
		//echo paragraph("Successfully connected");
		// <p>Successfully connected</p>
		return $link;
	}
}

function close_db() {
	mysql_close();
}

// Does database exist?
function select_db($database, $link) {
	if(mysql_select_db($database)) {
		//echo bold($database)." has been selected";
	} else {
		die("Unable to select database");
	}
}

// Does table exist?
function table_exist($table) {
	if(!(mysql_query("SELECT * FROM $table"))) {
		die("Table doesn't exist!");
	} else {
		echo("Table found");
	}
	
}
?>